<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        ul {
            list-style: none;
            /* 清除浮动1：直接设置高度 */
            /* height: 50px; */

        }

        /* 清除浮动2：给父级添加伪元素 */
        /* ul::after {
            content: '';
            display: block;
            clear: both;
        } */

        /* 清除浮动3双伪元素 */
        /* ul::after,
        ul::before {
            content: '';
            display: table;
        } */

        ul {

            /* 清除浮动4：overflow:hidden */
            overflow: hidden;
        }

        ul li {
            width: 80px;
            height: 50px;
            line-height: 50px;
            text-align: center;
            background: #ffc0cb;
            color: #fff;
            float: left;
        }

        ul li:hover {
            background: green;
        }
    </style>
</head>
<!-- 注意:
    只要写了浮动一定要给父元素清除浮动，不然会导致文档流不正常
    -->

<body>
    <ul>
        <li>新闻1</li>
        <li>新闻2</li>
        <li>新闻3</li>
        <li>新闻4</li>
        <li>新闻5</li>
        <li>新闻6</li>
        <li>新闻7</li>
        <li>新闻8</li>
    </ul>
</body>

</html>